<?php
# http://projects:8081/cdapp-2kt-api/api/capacity_record_query.php

include_once '_portal.php';

$start = $post->start;
$end = $post->end;
$order = $post->order;

$sql = "SELECT * FROM `2kt_capacity_record` WHERE `start` >= '{$start} 00:00:00' AND `end` <= '{$end} 23:59:59' ORDER BY `start` {$order}, `number` {$order}";
$res = exec_sql($sql);
if (!$res) {
  output(['payload' => [], 'sql' => $sql]);
} else {
  foreach ($res as $i => $r) {
    $res[$i]['content'] = json_parse($r['content']);
  }
  output(['payload' => $res, 'sql' => $sql]);
}
